<!-- addcourse:#upate_tab1   Author:liuricheng     Time:2013-10-01 -->
<style>
._tab1 *{vertical-align:middle;}.mb10{margin-bottom:10px;}._tab1 select{border:1px solid #848484;height:25px;width:225px;}
</style>

<div>
	<table  id="mytab"  border="1" class="t1" width="100%">
		<!--课程名称-->
		<tr>
			<th align="right" width="30%;">
				课堂名称
			</th>
			<td height="50">
				<input type="text" class="text input" name="name" value="{$course.name}"/>&nbsp;&nbsp;&nbsp;
				<span class="h_50 redtext">*</span>&nbsp;&nbsp;&nbsp;
				<b class="lovingtips" title="必须填写"></b>
			</td>
		</tr>
		<!--课程分类-->
		<tr>
			<th align="right">
				课堂分类
			</th>
			<td height="50">
				<select id="course_category_id" style="height:25px; width:220px;" name="course_category_id" value="">
					<option>{$lang.please_select_cat_name}</option>
					<volist name="courseCatList" id="courseCat">
						<option value="{$courseCat.id}">{$courseCat.name}</option>
					</volist>
				</select>&nbsp;&nbsp;&nbsp;
				<span class="h_50 redtext">*</span>&nbsp;&nbsp;&nbsp;
				<b class="lovingtips" title="请选择分类"></b>
				<span id="categoryValue" class="h_50" title=""></span>
			</td>
		</tr>
		<!--课程年龄分类-->
		<tr>
			<th align="right">
				{$lang.age_area}
			</th>
			<td height="50">
				<select id="age_id" name="age_id" style="height:25px; width:220px;">
					<volist name="agesList" id="ages">
						<option value="{$ages.id}">{$ages.name}</option>
					</volist>					
				</select>
			</td>
		</tr>
		<!--拓展分类-->
		<tr>
			<th align="right">
				拓展分类&nbsp;&nbsp;&nbsp;<a href="javascript:addOtherCat();" style="color:red;">[+添加]</a> 
			</th>
			<td height="50">				
				<div id="other_category">
					<volist name="OtherCatList" id="OtherCat">
						<select style="height:25px;" name="other_cat_id[]" value="">
							<option value="">请选择拓展分类</option>
							<volist name="OtherCat['cat_list']" id="cat_list">
								<if condition="$cat_list.id eq $OtherCat['selected']['id']">
									<option value="{$cat_list.id}" selected="ture">{$cat_list.name}</option>
								<else/>
									<option value="{$cat_list.id}">{$cat_list.name}</option>
								</if>
							</volist>
						</select>
					</volist>
				</div>
			</td>
		</tr>
		<!--课堂提供商-->
		<tr>
			<th align="right">
				提供商
			</th>
			<td>
				<select id="supplier_id" style="height:25px; width:220px;" name="supplier_id" value="">
					<volist name="supplierList" id="supplier">
						<option value="{$supplier.id}">{$supplier.name}</option>
					</volist>		
				</select>
			</td>
		</tr>
		<!--课堂价值积分-->
		<tr>
			<th align="right">
				{$lang.price}
			</th>
			<td>
				<input type="text" class="text input" name="integration" value="{$course.integration}"/>
			</td>
		</tr>	
		<!--课堂是否有效-->		
		<tr>
			<th align="right">
				{$lang.is_show}
			</th>
			<td>
				<input  type="radio" name="invalid" value="0"/>&nbsp;{$lang.yes}&nbsp;
				<input  type="radio" name="invalid" value="1"/>&nbsp;{$lang.no}
				<b class="lovingtips" title="若课程直接上架选择是"></b>
			</td>
		</tr>
		<!--课堂是否最新-->
		<tr>
			<th align="right">
				{$lang.is_new}
			</th>
			<td>
				<input type="radio" name="new" value="1"/>&nbsp;{$lang.yes}&nbsp;
				<input type="radio" name="new" value="0"/>&nbsp;{$lang.no}&nbsp;
				<b class="lovingtips" title="设置课程为最新课程,选择是"></b>
			</td>
		</tr>
		<!--课堂是否最热-->
		<tr>
			<th align="right">
				{$lang.is_hot}
			</th>						
			<td>
				<input type="radio" name="hot" value="1" />&nbsp;{$lang.yes}&nbsp;
				<input type="radio" name="hot" value="0" />&nbsp;{$lang.no}
				<b class="lovingtips" title="设置课程为最热课程,选择是"></b>
			</td>
		</tr>
		<!--课堂排序-->
		<tr>
			<th align="right">
				课堂排序
			</th>						
			<td>
				<input type="text"  class="text input" name="sort" value="{$course.sort}" /> 
				<b style="color:red;">*</b>&nbsp; 
				<b class="lovingtips" title="根据课程的顺序进行排序"></b>&nbsp;&nbsp;&nbsp;默认为50，必须是一个数字
			</td>
		</tr>
	</table>
</div>

<!-- [ 分类模板: 不能删除 ] -->
<select id="other_category_id" style="height:25px; display:none;"  value="">
	<option>{$lang.please_select_cat_name}</option>
	<volist name="courseCatList" id="courseCat">
		<option value="{$courseCat.id}">{$courseCat.name}</option>
	</volist>
</select>
<!-- [ 分类模板：不能删除 ] -->

<script>
	
	//初始化表单元素
	function initSelect(id,idValue){
		if(typeof id== 'undefined') return ;
		if(typeof idValue== 'undefined') return ;
		//id => obj
		var selectObj   =   document.getElementById(id);
		for(var i = 0; i < selectObj.options.length; i ++){
			if (selectObj.options[i].value == idValue) {        
				selectObj.options[i].selected = true; 
				break;        
			}        
		}		
	}
	
	//初始化
	initSelect('course_category_id',{$course.course_category_id});
	initSelect('age_id',{$course.age_id});	
	initSelect('supplier_id',{$course.supplier_id});	
	
	//初始化radio,checkbox
	function initInput(name,value){
		if(typeof name== 'undefined') return ;
		if(typeof value== 'undefined') return ;
		var inputObj   =   document.getElementsByName(name);
		
		for(var i = 0; inputObj.length; i ++ ){
			//alert(inputObj[i].value + " : " + value);
			if(inputObj[i].value == value){
				inputObj[i].checked = true;
				break;
			}
		}		
	}
	
	//初始化input
	initInput('invalid',{$course.invalid});
	initInput('new',{$course.new});
	initInput('hot',{$course.hot});
	
	//添加拓展分类
	function addOtherCat(){
		var other_category_panel	=	$('#other_category');
		var select_obj				=	other_category_panel.find('select:first');
		var select_clone			=	null;
		// select_obj.innerHTML === 'undefined'
		if(typeof select_obj.innerHTML == 'undefined'){
			select_obj				=	$('#other_category_id');
			var select_clone		=	select_obj.clone();
			// set prototypes
			select_clone.attr('name','other_cat_id[]');
			select_clone.show();
			other_category_panel.append(select_clone);
		}
		else{
			select_clone			=	select_obj.clone();
			//insert after
			other_category_panel.append(select_clone);
		}
	}
	
	$(document).ready(function(){		
		/* 气泡提示框 */
		$('a[title]').qtip({ 
			style: { name: 'green'/* black,cream,green,dark,light,red,blue */, tip: true },
			position: { adjust: { screen: true } } /* 根据位置自动调整 */
		});
		/* 填写提示 */
		$('b[title]').qtip({ 
			style: { name: 'cream'/* black,cream,green,dark,light,red,blue */, tip: true },
			position: { adjust: { screen: true } } /* 根据位置自动调整 */
		});
		
		$('#nihao').click(function(){
			$('#loading').QLoading({'text':'处理中','status':'open','model':true});
		});
	});

</script>














